<template>
    <div>
    <h1>房号信息列表展示</h1>
    <a href="/AddView">房号信息录入</a>
    <br>
    <a href="/ShowPriceView">房价信息列表展示</a>
    <br>
    门店名称:  <select v-model="find.memberid">
                        <option value="0">请选择</option>
                        <option v-for="b in qwert" :value="b.memberId">{{ b.name }}</option>
                     </select>
     房型名称： <select v-model="find.roomtypeid">
                        <option value="0">请选择</option>
                        <option v-for="c in qwery" :value="c.roomTypeId">{{ c.name }}</option>
                     </select>
     <input type="button" value="查询" @click="Show">
     <table class="table">
        <thead>
            <tr>
                <td>房号</td>
                <td>门店名称</td>
                <td>房型名称</td>
                <td>排序</td>
                <td>状态</td>
                <td>操作</td>
                
            </tr>
        </thead>
        <tbody>
            <tr v-for="a in data">
                 <td>{{ a.roomId }}</td>
                <td>{{a.memberName  }}</td>
                <td>{{a.typeName  }}</td>
                <td>{{a.paixu  }}</td>
                <td>{{a.start==1?"上架":"下架"  }}</td>
                <td><input type="button" value="逻辑删除" @click="DelRoom(a.id)">
                <input type="button" value="修改状态" @click="UptStart(a.id)"></td>
            </tr>
        </tbody>
     </table>
    </div>

</template>

<script setup lang="ts">
import {ref,onMounted} from "vue"
import axios from 'axios';
onMounted(()=>{
    Show();
    Xiala();
    Xialak();
})
const data=ref([{
    "roomId": 1001,
    "id": 2,
    "roomTypeId": 2,
    "memberId": 3,
    "paixu": 1,
    "start": 1,
    "typeName": "双人房",
    "memberName": "顺丰大酒店"
}])
const Show=()=>{
    axios.get("https://localhost:7162/api/RoomModel/GetRoom",{params:find.value}).then(res=>{
        data.value=res.data
      
    })
}
const find=ref({
   roomtypeid:0,
   memberid:0
})
const qwert=ref([{
      "memberId": 3,
    "name": "顺丰大酒店",
}])
const Xiala=()=>{
    axios.get("https://localhost:7162/api/RoomModel/Xiala").then(res=>{
        qwert.value=res.data
    })
}
const qwery=ref([{
     "roomTypeId": 1,
    "name": "单人房"
}])
const Xialak=()=>{
    axios.get("https://localhost:7162/api/RoomModel/Xialak").then(res=>{
        qwery.value=res.data
    })
}
const UptStart=(id:any)=>{
    if(!confirm('确认修改吗？')){
        return;
    }
    axios.get("https://localhost:7162/api/RoomModel/UptStart",{params:{id:id}}).then(res=>{
        if(res.data>0){
            alert('修改成功');
            Show()
        }
        else{
            alert('修改失败');
        }
    })
}
const DelRoom=(id:any)=>{
    if(!confirm('确认删除吗？')){
        return;
    }
    axios.delete("https://localhost:7162/api/RoomModel/DelRoom",{params:{id:id}}).then(res=>{
        if(res.data>0){
            alert('删除成功');
            Show()
        }
        else{
            alert('删除失败');
        }
    })
}
</script>

<style scoped>

</style>